from sklearn.decomposition import PCA


class ExtractFeature:

    def __init__(self, method):
        self._defaults = ['pca']
        assert method in self._defaults, "method should in {}".format(self._defaults)

        self.features_name = None
        self.x = None
        self.y = None
        self.features_num = -1
        self.dtypes = None

    def _set_params(self, x, y, feature):
        self.x = x
        self.y = y
        self.features_name = feature

        self.features_num = x.shape[0]

        self.dtypes = str(y.dtype)

    def fit(self, x, y=None, feature=None):
        self._set_params(x, y, feature)
        m = PCA()

        dt = m.fit(x)

        return dt
